package cn.wanghaomiao.dao;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import cn.wanghaomiao.model.University;
import cn.wanghaomiao.util.TimeUtil;

/**
 * 
 * @author 胡宇鹏
 * 
 */
public class UniversityDao {

	/**
	 * 将university对象保存到数据库中
	 */
	public static void insert(University univ) {
		List<String> univNames = univ.getUniv_name();
		List<String> univUrls = univ.getUniv_url();
		
		for (int i = 0; i < univNames.size(); i++) {
			// 存在抓取的学校名字为空的情况
			if (StringUtils.isNotBlank(univNames.get(i))){
				HBaseDao.insert("university", TimeUtil.getTimeStamp(), "info", "univName",univNames.get(i).toString());
			}
		}
		
		for(int i = 0; i < univUrls.size(); i++){
			//存在链接为" http://tieba.baidu.com/f?kw= " 的情况
			if(univUrls.get(i).length()>28){
				HBaseDao.insert("university", TimeUtil.getTimeStamp(), "info", "univUrl",univUrls.get(i).toString());
			}
			
		}
	}
}
